package com.douwong.student.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.bumptech.glide.Glide;
import com.douwong.student.R;
import com.douwong.student.base.BaseActivity;
import com.douwong.student.rxjava.EndPointInterface;
import com.douwong.student.utils.ScreenUtils;
import com.douwong.student.view.ScaleImageView;

/**
 * @autor yichao
 * @time 2017/4/1816:07
 * @des 查看手写互动图片
 */
public class HandWrittenImagView extends BaseActivity {

    private ScaleImageView mScaleImageView;
    private Bitmap mBitmap;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_handwritten_imag);
        mScaleImageView = (ScaleImageView) findViewById(R.id.hand_written_image_scale);
    }

    @Override
    protected void initData() {
        super.initData();
        Intent intent = getIntent();
        String filePath = intent.getStringExtra("filePath");
       String type= intent.getStringExtra("type");
        if (type==null){
            mBitmap = BitmapFactory.decodeFile(filePath);
            if (mBitmap != null) {
                mScaleImageView.setDispResource(mBitmap, ScreenUtils.getScreenWidth(), ScreenUtils.getScreenHeight());
            }
        }else {
            Glide.with(this).load(EndPointInterface.HEAD_PIC+filePath).into(mScaleImageView);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mBitmap!=null && !mBitmap.isRecycled()){
            mBitmap.recycle();
            mBitmap=null;
            System.gc();

        }
    }
}
